package com.qf.service.impl;

import com.qf.dao.UserMapper;
import com.qf.pojo.User;
import com.qf.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


@Service
public class UserServiceImpl implements UserService {

    @Autowired
    UserMapper userMapper;

    @Override
    public User login(String tel) {

        User user = userMapper.findByTel(tel);

//        if(user.getTel()==null){
//            throw new RuntimeException("手机号码错误");
//        }
//        if(!user.getPassword().equals(password)){
//            throw new RuntimeException("密码错误");
//        }

        return user;
    }

    @Override
    public Integer register(User user) {

        User byTel = userMapper.findByTel(user.getTel());
        if(byTel==null){
            return userMapper.register(user);
        }
        return 0;
    }

    @Override
    public User findByTel(String tel) {
        return userMapper.findByTel(tel);
    }

    @Override
    public Integer updateInfo(User user) {
        return userMapper.updateInfo(user);
    }

}
